package com.sinopec.basemodule.utils

import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import com.alibaba.android.arouter.launcher.ARouter
import com.sinopec.basemodule.model.StockInListModel
import com.sinopec.basemodule.model.StockOutListModel

/**
 * 类描述：ARouter管理类
 */
object ARouterManagerUtils {

    //登录界面
    const val GOTO_MAIN_LOGIN_ACTIVITY = "/main/LoginActivity"

    //我的界面
    const val GOTO_MAIN_MINE_FRAGMENT = "/main/MineFragment"

    //uhf设置界面
    const val GOTO_UHF_SET_ACTIVITY = "/uhf/uhfSetActivity"

    //跳转到无数据fragment
    const val GOTO_BM_NO_DATA_FRAGMENT = "/bm/NoDataFragment"

    //错误托盘校验结果界面
    const val GOTO_MAIN_ERROR_CODE_LIST_ACTIVITY = "/main/ErrorCodeListActivity"

    //已读有效编码查看界面
    const val GOTO_MAIN_NORMAL_CODE_LIST_ACTIVITY = "/main/NormalCodeListActivity"

    /**
     * 登录界面
     */
    @JvmStatic
    fun gotoLogin() {
        ARouter.getInstance().build(GOTO_MAIN_LOGIN_ACTIVITY).navigation()
    }

    /**
     * 跳转到uhf扫rfid设置界面
     */
    @JvmStatic
    fun gotoUhfSetScan() {
        ARouter.getInstance().build(GOTO_UHF_SET_ACTIVITY).navigation()
    }

    /**
     * 我的tab
     */
    @JvmStatic
    fun gotoMineFragment(): Fragment {
        return ARouter.getInstance()
            .build(GOTO_MAIN_MINE_FRAGMENT)
            .navigation()
                as Fragment
    }

    /**
     * 已读有效编码查看界面
     */
    @JvmStatic
    fun gotoNormalCodeListActivity(activity: AppCompatActivity, palletCodes: ArrayList<String>) {
        ARouter.getInstance()
            .build(GOTO_MAIN_NORMAL_CODE_LIST_ACTIVITY)
            .withStringArrayList("palletCodes", palletCodes)
            .navigation()
    }

    /**********************入库module************************/
    //入库扫码
    const val GOTO_UHF_IN_ACTIVITY = "/uhf/uhfInActivity"

    //入库列表
    const val GOTO_MAIN_STOCK_IN_FRAGMENT = "/main/StockInListFragment"

    //入库详情
    const val GOTO_MAIN_STOCK_IN_DETAIL_ACTIVITY = "/main/StockInDetailActivity"

    /**
     * 入库tab
     */
    @JvmStatic
    fun gotoStockInFragment(): Fragment {
        return ARouter.getInstance()
            .build(GOTO_MAIN_STOCK_IN_FRAGMENT)
            .navigation()
                as Fragment
    }

    /**
     * 跳转到入库详情界面
     */
    @JvmStatic
    fun gotoStockInDetailActivity(activity: AppCompatActivity, stockInListModel: StockInListModel) {
        ARouter.getInstance()
            .build(GOTO_MAIN_STOCK_IN_DETAIL_ACTIVITY)
            .withParcelable("stockInListModel", stockInListModel)
            .navigation()
    }

    /**********************出库module************************/
    //出库扫码
    const val GOTO_UHF_OUT_ACTIVITY = "/uhf/uhfOutActivity"

    //出库列表
    const val GOTO_MAIN_STOCK_OUT_FRAGMENT = "/main/StockOutListFragment"

    //出库详情
    const val GOTO_MAIN_STOCK_OUT_DETAIL_ACTIVITY = "/main/StockOutDetailActivity"

    /**
     * 出库tab
     */
    @JvmStatic
    fun gotoStockOutFragment(): Fragment {
        return ARouter.getInstance()
            .build(GOTO_MAIN_STOCK_OUT_FRAGMENT)
            .navigation() as Fragment
    }

    /**
     * 跳转到出库详情界面
     */
    @JvmStatic
    fun gotoStockOutDetailActivity(
        activity: AppCompatActivity,
        stockOutListModel: StockOutListModel,
    ) {
        ARouter.getInstance()
            .build(GOTO_MAIN_STOCK_OUT_DETAIL_ACTIVITY)
            .withParcelable("stockOutListModel", stockOutListModel)
            .navigation()
    }
    ///////////////////////////////////////end/////////////////////////////////////////////

    /**********************盘库module************************/
    //日常盘点-获取包装规格列表
    const val GOTO_MAIN_DAILY_INVENTORY_ACTIVITY = "/main/DailyInventoryListActivity"

    //日常盘点扫码
    const val GOTO_UHF_DAILY_INVENTORY_ACTIVITY = "/uhf/uhfDailyInventoryActivity"

    /**
     * 跳转到日常盘点-获取包装规格列表界面
     */
    @JvmStatic
    fun gotoDailyInventoryListActivity(
        activity: AppCompatActivity,
    ) {
        ARouter.getInstance()
            .build(GOTO_MAIN_DAILY_INVENTORY_ACTIVITY)
            .navigation()
    }
}